package xiancheng.yield;

/**
 * @author Mr.ma
 * @since 2022/11/1 15:28
 * yield方法
 **/
public class Test06 {
    public static void main(String[] args) {
        TestRunnable01 testRunnable01 = new TestRunnable01();
        Thread thread1 = new Thread(testRunnable01);
        Thread thread2 = new Thread(testRunnable01);
        Thread thread3 = new Thread(testRunnable01);
        thread1.start();
        thread2.start();
        thread3.start();
        for (int i = 0; i < 200; i++) {
            System.out.println(Thread.currentThread().getName() + " ==== " + i);
        }
    }
}
class TestRunnable01 implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i <200; i++) {
            if (i == 100){
                Thread.yield();
            }
            System.out.println(Thread.currentThread().getName() + "====" + i);
        }
    }
}